package com.niit.service;

import com.niit.model.*;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author： 雷雨
 * @date: 2021/6/16
 * @description:
 *  写相关服务降级的方法
 * @modified:
 * @Version: 1.0
 */
@Component
public class StudentFallbackFactory implements FallbackFactory<StudentService> {


    @Override
    public StudentService create(Throwable cause) {
        return new StudentService() {
            @Override
            public List<Classes> getClassById(Long id) {
                Classes classes=new Classes();
                classes.setClass_name("服务降级");
                List<Classes> classes1=new ArrayList<>();
                classes1.add(classes);
                return classes1;
            }

            @Override
            public List<StudentPaperQuestionAnswer> selectForPaper(Long id){
                return null;
            }
            @Override
            public String deleteClassById(Long id1, Long id2) {
                return "success";
            }

            @Override
            public List<ExamPaper> list(Long id) {
                ExamPaper examPaper=new ExamPaper();
                examPaper.setId_class(1);
                List<ExamPaper> s2=new ArrayList<>();
                s2.add(examPaper);
                return s2;
            }

            @Override
            public List<ExamPaper> list1(Long id) {
                ExamPaper examPaper=new ExamPaper();
                examPaper.setId_class(1);
                List<ExamPaper> s2=new ArrayList<>();
                s2.add(examPaper);
                return s2;
            }

            @Override
            public List<ExamPaper> list2(Long id) {
                ExamPaper examPaper=new ExamPaper();
                examPaper.setId_class(1);
                List<ExamPaper> s2=new ArrayList<>();
                s2.add(examPaper);
                return s2;
            }


            @Override
            public ExamPaper getExamPaperById(Long id) {
                ExamPaper examPaper=new ExamPaper();
                examPaper.setPaper_name("服务降级");
                return examPaper;
            }

            @Override
            public ExamPaper getExamPaperById1(Long id) {
                ExamPaper examPaper=new ExamPaper();
                examPaper.setPaper_name("服务降级");
                return examPaper;
            }

            @Override
            public ExamPaper getExamPaperById2(Long id) {
                ExamPaper examPaper=new ExamPaper();
                examPaper.setPaper_name("服务降级");
                return examPaper;
            }

            @Override
            public Student getStudentById(Long id) {
                Student student=new Student();
                student.setName("服务降级");
                return student;
            }

            @Override
            public String update(Student student) {
                return "qaq";
            }

            @Override
            public List<StudentPaper> selectStudentPaperById(Long id) {
                StudentPaper studentPaper=new StudentPaper();
                studentPaper.setMark(1);
                List<StudentPaper> s2=new ArrayList<>();
                s2.add(studentPaper);
                return s2;
            }

            @Override
            public List<StudentPaper> list(StudentPaper studentPaper) {
                StudentPaper e=new StudentPaper();
                e.setMark(1);
                List<StudentPaper> s2=new ArrayList<>();
                s2.add(e);
                return s2;
            }

            @Override
            public String add(StudentPaperQuestionAnswer studentPaperQuestionAnswer) {
                return "qaq";
            }

            @Override
            public String update(StudentPaperQuestionAnswer studentPaperQuestionAnswer) {
                return "qaq";
            }

            @Override
            public StudentPaperQuestionAnswer select1(Long id1, Long id2) {
                StudentPaperQuestionAnswer studentPaperQuestionAnswer=new StudentPaperQuestionAnswer();
                studentPaperQuestionAnswer.setStudent_answer("服务降级");
                return studentPaperQuestionAnswer;
            }

            @Override
            public PaperQuestion select(Long id1, Long id2) {
                PaperQuestion paperQuestion=new PaperQuestion();
                paperQuestion.setId_paper(1);
                return paperQuestion;
            }

            @Override
            public int addStudentClassById(Long id1, Long id2) {
                return 0;
            }

            @Override
            public Student Login(Long id, String password) {
                Student student =new Student();
                student.setName("weqqe");
                return student;
            }
        };
    }
}
